/**
 * 
 * @param imgFile 
 * @param type 
 * @returns 
 */
 export function createLocalImageUrl(imgFile: File, type: 'fileReader'|'URL' = 'URL'): Promise<[string|null,string, () => void]> {
    if(type === 'URL') {
        try {
            let src = URL.createObjectURL(imgFile);
            return Promise.resolve([null, src, () => {
                URL.revokeObjectURL(src);
            }]);
        } catch (error) {
            console.error(error);
            return Promise.resolve(['error', '', () => {}]);
        }
    } else {
        const fileReader = new FileReader();
        fileReader.readAsDataURL(imgFile);
        return new Promise(resolve => {
            fileReader.onload = function(event) {
                // @ts-ignore
                resolve([null, event.target.result, () => {}]);
            }
        });
    }
}